package com.book.controller;

import java.util.Arrays;
import java.util.Map;

import com.book.entity.BookPictureEntity;
import com.book.service.BookPictureService;
import com.book.utils.PageUtils;
import com.book.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 
 *
 * @author yang
 * @email yang@gmail.com
 * @date 2020-12-05 14:30:35
 */
@RestController
@RequestMapping("/book/picture")
public class BookPictureController {
    @Autowired
    private BookPictureService bookPictureService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bookPictureService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		BookPictureEntity bookPicture = bookPictureService.getById(id);

        return R.ok().put("bookPicture", bookPicture);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BookPictureEntity bookPicture){
		bookPictureService.save(bookPicture);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BookPictureEntity bookPicture){
		bookPictureService.updateById(bookPicture);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		bookPictureService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
